#!usr/bin/env python3

import socket    
from config import HOST,PORT
from packUtils import packData,unpackData

class GameClient(object):
    def __init__(self,host,port):
        self.host = host
        self.port = port
        self.conn = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        self.conn.connect((host,port))
        
        
    def recData(self):#接收服务器推送的数据
        while True:
            rev = self.conn.recv(1024)
            print("------------ rev=",rev.decode('utf-8'))
            
    #发送数据;data:封包后的数据    
    def sendData(self,data):        
        self.conn.send(data)

if __name__=="__main__":
    c = GameClient(HOST,PORT)
    longStr = 'ServerSock你好'*300
    data,fmt = packData(1001,['Hello'.encode('utf-8'),longStr.encode('utf-8'),50,999888])    
    c.sendData(data)
    c.recData()   

        
    
    